#include <REGX52.H>
#include "Delay.h"
#include "Timer0.h"


sbit DA = P2^1;


unsigned char Compare;


void main()
{
	unsigned char i = 0;
	Timer0_Init();
	while(1)
	{
		for (i = 0;i < 100;i++)
		{
			Compare = i;
			Delay(10);
		}
		for (i = 100;i > 0;i--)
		{
			Compare = i;
			Delay(10);
		}
	}
}


void Timer0_Rountine() interrupt 1
{	
	static unsigned int T0Count = 0;	
	
	TL0 = 0xA4;		//设置定时初值
	TH0 = 0xFF;		//设置定时初值
	
	T0Count++;
	T0Count %= 100;
	if (T0Count < Compare)
	{
		DA = 1;
	}
	else
	{
		DA = 0;
	}
}





















